﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DetectScars.mQLel
{
    class PlcDataAddress
    {
        public static string position = "position";
        public static string err_msg = "err_msg";
        public static string v_jog = "v_jog";
        public static string v_rel = "v_rel";
        public static string v_abs = "v_abs";
        public static string p_rel = "p_rel";
        public static string p_abs = "p_abs";
        public static string p_rel_don = "p_rel_don";
        public static string p_abs_don = "p_abs_don";
        public static string p_rel_run = "p_rel_run";
        public static string p_abs_run = "p_abs_run";
        public static string home_don = "home_don";
        public static string reset_don = "reset_don";
        public static string stop_don = "stop_don";
        public static string err = "err";
        public static string home = "home";
        public static string reset = "reset";
        public static string stop = "stop";
        public static string jog_f = "jog_f";
        public static string jog_b = "jog_b";
        public static string getAddress(string asix,string pos){
            string address = "";
            if(asix == "X")
            {
                if (pos== position)
                {
                    address = x_position;
                }
                else if(pos== err_msg)
                {
                    address = x_err_msg;
                }
                else if (pos == v_jog)
                {
                    address = x_velocity_jog;
                }
                else if (pos == v_rel)
                {
                    address = x_velocity_rel;
                }
                else if (pos == v_abs)
                {
                    address = x_velocity_abs;
                }
                else if (pos == p_rel)
                {
                    address = x_position_rel;
                }
                else if (pos == p_abs)
                {
                    address = x_position_abs;
                }
                else if (pos == p_rel_don)
                {
                    address = x_position_rel_don;
                }
                else if (pos == p_abs_don)
                {
                    address = x_position_abs_don;
                }
                else if (pos == home_don)
                {
                    address = x_home_don;
                }
                else if (pos == reset_don)
                {
                    address = x_reset_don;
                }
                else if (pos == stop_don)
                {
                    address = x_stop_don;
                }
                else if (pos == err)
                {
                    address = x_err;
                }
                else if (pos == home)
                {
                    address = x_home;
                }
                else if (pos == reset)
                {
                    address = x_reset;
                }
                else if (pos == stop)
                {
                    address = x_stop;
                }
                else if (pos == jog_f)
                {
                    address = x_jog_f;
                }
                else if (pos == jog_b)
                {
                    address = x_jog_b;
                }
                else if (pos == p_abs_run)
                {
                    address = x_position_abs_run;
                }
                else if (pos == p_rel_run)
                {
                    address = x_position_rel_run;
                }

            }
            else if(asix == "Y")
            {
                if (pos == "velocity")
                {
                    address = c_velocity;
                }
                else if (pos == "zz")
                {
                    address = c_zz;
                }
                else if (pos == "fz")
                {
                    address = c_fz;
                }
            }
            else if (asix == "Z")
            {
                if (pos == position)
                {
                    address = z_position;
                }
                else if (pos == err_msg)
                {
                    address = z_err_msg;
                }
                else if (pos == v_jog)
                {
                    address = z_velocity_jog;
                }
                else if (pos == v_rel)
                {
                    address = z_velocity_rel;
                }
                else if (pos == v_abs)
                {
                    address = z_velocity_abs;
                }
                else if (pos == p_rel)
                {
                    address = z_position_rel;
                }
                else if (pos == p_abs)
                {
                    address = z_position_abs;
                }
                else if (pos == p_rel_don)
                {
                    address = z_position_rel_don;
                }
                else if (pos == p_abs_don)
                {
                    address = z_position_abs_don;
                }
                else if (pos == home_don)
                {
                    address = z_home_don;
                }
                else if (pos == reset_don)
                {
                    address = z_reset_don;
                }
                else if (pos == stop_don)
                {
                    address = z_stop_don;
                }
                else if (pos == err)
                {
                    address = z_err;
                }
                else if (pos == home)
                {
                    address = z_home;
                }
                else if (pos == reset)
                {
                    address = z_reset;
                }
                else if (pos == stop)
                {
                    address = z_stop;
                }
                else if (pos == jog_f)
                {
                    address = z_jog_f;
                }
                else if (pos == jog_b)
                {
                    address = z_jog_b;
                }
                else if (pos == p_abs_run)
                {
                    address = z_position_abs_run;
                }
                else if (pos == p_rel_run)
                {
                    address = z_position_rel_run;
                }
            }
            else if (asix == "W")
            {
                if (pos == position)
                {
                    address = w_position;
                }
                else if (pos == err_msg)
                {
                    address = w_err_msg;
                }
                else if (pos == v_jog)
                {
                    address = w_velocity_jog;
                }
                else if (pos == v_rel)
                {
                    address = w_velocity_rel;
                }
                else if (pos == v_abs)
                {
                    address = w_velocity_abs;
                }
                else if (pos == p_rel)
                {
                    address = w_position_rel;
                }
                else if (pos == p_abs)
                {
                    address = w_position_abs;
                }
                else if (pos == p_rel_don)
                {
                    address = w_position_rel_don;
                }
                else if (pos == p_abs_don)
                {
                    address = w_position_abs_don;
                }
                else if (pos == home_don)
                {
                    address = w_home_don;
                }
                else if (pos == reset_don)
                {
                    address = w_reset_don;
                }
                else if (pos == stop_don)
                {
                    address = w_stop_don;
                }
                else if (pos == err)
                {
                    address = w_err;
                }
                else if (pos == home)
                {
                    address = w_home;
                }
                else if (pos == reset)
                {
                    address = w_reset;
                }
                else if (pos == stop)
                {
                    address = w_stop;
                }
                else if (pos == jog_f)
                {
                    address = w_jog_f;
                }
                else if (pos == jog_b)
                {
                    address = w_jog_b;
                }
                else if (pos == p_abs_run)
                {
                    address = w_position_abs_run;
                }
                else if (pos == p_rel_run)
                {
                    address = w_position_rel_run;
                }
                if (pos == "zdsd")
                {
                    address = w_zdsd;
                }
                else if (pos == "njms")
                {
                    address = w_njms;
                }
                else if (pos == "wzms")
                {
                    address = w_wzms;
                }
                else if (pos == "niuju")
                {
                    address = w_niuju;
                }
                else if (pos == "njqd")
                {
                    address = w_njqd;
                }
            }
            else if (asix == "U")
            {
                if (pos == position)
                {
                    address = u_position;
                }
                else if (pos == err_msg)
                {
                    address = u_err_msg;
                }
                else if (pos == v_jog)
                {
                    address = u_velocity_jog;
                }
                else if (pos == v_rel)
                {
                    address = u_velocity_rel;
                }
                else if (pos == v_abs)
                {
                    address = u_velocity_abs;
                }
                else if (pos == p_rel)
                {
                    address = u_position_rel;
                }
                else if (pos == p_abs)
                {
                    address = u_position_abs;
                }
                else if (pos == p_rel_don)
                {
                    address = u_position_rel_don;
                }
                else if (pos == p_abs_don)
                {
                    address = u_position_abs_don;
                }
                else if (pos == home_don)
                {
                    address = u_home_don;
                }
                else if (pos == reset_don)
                {
                    address = u_reset_don;
                }
                else if (pos == stop_don)
                {
                    address = u_stop_don;
                }
                else if (pos == err)
                {
                    address = u_err;
                }
                else if (pos == home)
                {
                    address = u_home;
                }
                else if (pos == reset)
                {
                    address = u_reset;
                }
                else if (pos == stop)
                {
                    address = u_stop;
                }
                else if (pos == jog_f)
                {
                    address = u_jog_f;
                }
                else if (pos == jog_b)
                {
                    address = u_jog_b;
                }
                else if (pos == p_abs_run)
                {
                    address = u_position_abs_run;
                }
                else if (pos == p_rel_run)
                {
                    address = u_position_rel_run;
                }
            }
            else if (asix == "V")
            {
                if (pos == position)
                {
                    address = v_position;
                }
                else if (pos == err_msg)
                {
                    address = v_err_msg;
                }
                else if (pos == v_jog)
                {
                    address = v_velocity_jog;
                }
                else if (pos == v_rel)
                {
                    address = v_velocity_rel;
                }
                else if (pos == v_abs)
                {
                    address = v_velocity_abs;
                }
                else if (pos == p_rel)
                {
                    address = v_position_rel;
                }
                else if (pos == p_abs)
                {
                    address = v_position_abs;
                }
                else if (pos == p_rel_don)
                {
                    address = v_position_rel_don;
                }
                else if (pos == p_abs_don)
                {
                    address = v_position_abs_don;
                }
                else if (pos == home_don)
                {
                    address = v_home_don;
                }
                else if (pos == reset_don)
                {
                    address = v_reset_don;
                }
                else if (pos == stop_don)
                {
                    address = v_stop_don;
                }
                else if (pos == err)
                {
                    address = v_err;
                }
                else if (pos == home)
                {
                    address = v_home;
                }
                else if (pos == reset)
                {
                    address = v_reset;
                }
                else if (pos == stop)
                {
                    address = v_stop;
                }
                else if (pos == jog_f)
                {
                    address = v_jog_f;
                }
                else if (pos == jog_b)
                {
                    address = v_jog_b;
                }
                else if (pos == p_abs_run)
                {
                    address = v_position_abs_run;
                }
                else if (pos == p_rel_run)
                {
                    address = v_position_rel_run;
                }
            }
            else
            {
                if(pos == stop)
                {
                    address = stop_all;
                }
            }
            return address;
        }
        // 30 12 31 36
        //QL 10
        //当前位置
        private static string x_position = "QL27";
        private static string z_position = "QL28";
        private static string w_position = "QL29";
        private static string u_position = "QL30";
        private static string v_position = "QL31";
        //轴异常码
        private static string x_err_msg = "";
        private static string z_err_msg = "";
        private static string w_err_msg = "";
        private static string u_err_msg = "";
        private static string v_err_msg = "";
        //IL 25
        //绝对速度 相对速度 点速度 绝对位置 相对位置
        private static string x_velocity_abs = "IL0";
        private static string x_velocity_rel = "IL1";
        private static string x_velocity_jog = "IL2";
        private static string x_position_abs = "IL3";
        private static string x_position_rel = "IL4";

        private static string z_velocity_abs = "IL5";
        private static string z_velocity_rel = "IL6";
        private static string z_velocity_jog = "IL7";
        private static string z_position_abs = "IL8";
        private static string z_position_rel = "IL9";

        private static string w_velocity_abs = "IL10";
        private static string w_velocity_rel = "IL11";
        private static string w_velocity_jog = "IL12";
        private static string w_position_abs = "IL13";
        private static string w_position_rel = "IL14";

        private static string u_velocity_abs = "IL15";
        private static string u_velocity_rel = "IL16";
        private static string u_velocity_jog = "IL17";
        private static string u_position_abs = "IL18";
        private static string u_position_rel = "IL19";

        private static string v_velocity_abs = "IL20";
        private static string v_velocity_rel = "IL21";
        private static string v_velocity_jog = "IL22";
        private static string v_position_abs = "IL23";
        private static string v_position_rel = "IL24";

        

        //QX 绝对完成 相对完成 回零完成 复位完成 停止完成
        private static string x_position_abs_don = "QX0.0";
        private static string x_position_rel_don = "QX0.1";
        private static string x_home_don = "QX0.2";
        private static string x_reset_don = "QX0.3";
        private static string x_stop_don = "QX0.4";
        private static string x_err = "QX0.5";

        private static string z_position_abs_don = "QX0.6";
        private static string z_position_rel_don = "QX0.7";
        private static string z_home_don = "QX1.0";
        private static string z_reset_don = "QX1.1";
        private static string z_stop_don = "QX1.2";
        private static string z_err = "QX1.3";

        private static string w_position_abs_don = "QX1.4";
        private static string w_position_rel_don = "QX1.5";
        private static string w_home_don = "QX1.6";
        private static string w_reset_don = "QX1.7";
        private static string w_stop_don = "QX2.0";
        private static string w_err = "QX2.1";

        private static string u_position_abs_don = "QX2.2";
        private static string u_position_rel_don = "QX2.3";
        private static string u_home_don = "QX2.4";
        private static string u_reset_don = "QX2.5";
        private static string u_stop_don = "QX2.6";
        private static string u_err = "QX2.7";

        private static string v_position_abs_don = "QX3.0";
        private static string v_position_rel_don = "QX3.1";
        private static string v_home_don = "QX3.2";
        private static string v_reset_don = "QX3.3";
        private static string v_stop_don = "QX3.4";
        private static string v_err = "QX3.5";

        //IX 绝对运行开始 相对运行开始 回零 反向点动 正向点动 复位 停止
        private static string x_position_abs_run = "IX0.0";
        private static string x_position_rel_run = "IX0.1";
        private static string x_home = "IX0.2";
        private static string x_jog_b = "IX0.3";
        private static string x_jog_f = "IX0.4";
        private static string x_reset = "IX0.5";
        private static string x_stop = "IX0.6";

        private static string z_position_abs_run = "IX0.7";
        private static string z_position_rel_run = "IX1.0";
        private static string z_home = "IX1.1";
        private static string z_jog_b = "IX1.2";
        private static string z_jog_f = "IX1.3";
        private static string z_reset = "IX1.4";
        private static string z_stop = "IX1.5";

        private static string w_position_abs_run = "IX1.6";
        private static string w_position_rel_run = "IX1.7";
        private static string w_home = "IX2.0";
        private static string w_jog_b = "IX2.1";
        private static string w_jog_f = "IX2.2";
        private static string w_reset = "IX2.3";
        private static string w_stop = "IX2.4";

        private static string u_position_abs_run = "IX2.5";
        private static string u_position_rel_run = "IX2.6";
        private static string u_home = "IX2.7";
        private static string u_jog_b = "IX3.0";
        private static string u_jog_f = "IX3.1";
        private static string u_reset = "IX3.2";
        private static string u_stop = "IX3.3";

        private static string v_position_abs_run = "IX3.4";
        private static string v_position_rel_run = "IX3.5";
        private static string v_home = "IX3.6";
        private static string v_jog_b = "IX3.7";
        private static string v_jog_f = "IX4.0";
        private static string v_reset = "IX4.1";
        private static string v_stop = "IX4.2";

        //C轴 变频速度 正转 反转
        private static string c_velocity = "IW104";
        private static string c_fz = "IX4.3";
        private static string c_zz = "IX4.4";
        //W轴 位置模式 扭矩模式 最大速度 扭矩启动
        private static string w_wzms = "IX4.6";
        private static string w_njms = "IX4.5";
        private static string w_zdsd = "ID53";
        private static string w_njqd = "IX4.7";
        private static string w_niuju = "IL25";
        public static string w_mslx = "QW128";
        //急停
        private static string stop_all = "IX5.0";
    }
}
